import {defineStore} from 'pinia'
export default defineStore('address',{
	actions:{
		addshaddress(data){
			if(!this.shaddress.length){
				this.selcetaddressid=data.id
			}
			 this.shaddress.unshift(data)
			 console.log(data)
		}
	},
	state(){
		return {
			address:"",
			shaddress:[],
			selcetaddressid:0
		}
	},
	getters:{
		 curraddress(){
			 if(!this.selcetaddressid){
				 return false
			 }
			 return this.shaddress.find(e=>e.id==this.selcetaddressid)
		 }
	},
	unistorage:{
		paths:['shaddress','selcetaddressid']
	}
})